//
//  VPODataModel.m
//  VPOS3695Demo
//
//  Created by stonesMonkey on 2018/7/21.
//  Copyright © 2018年 张玉风. All rights reserved.
//

#import "VPODataModel.h"

@implementation VPODataModel

+ (instancetype)modelWithDict:(NSDictionary *)dict {
    
   VPODataModel *model = [VPODataModel new];
    
    if (dict ==nil) {
        return model;
    }
    model.action = dict[@"action"];
    
     model.arg1 = [dict[@"arg1"] integerValue];
     model.arg2 = [dict[@"arg2"] integerValue];
     model.dName = dict[@"dName"];
     model.param1 = dict[@"param1"];
     model.param2 = dict[@"param2"];
     model.param3 = dict[@"param3"];
     model.resultCode = [dict[@"resultCode"] integerValue];
    model.resultMsg = dict[@"resultMsg"];
//    [model setValuesForKeysWithDictionary:dict];
    NSString *dataStr = dict[@"data"];
    if (dataStr != nil && dataStr.length != 0 ) {
        
        NSDictionary *detailDict = [ZYFDataConversionTool dictionaryWithJsonString:dataStr];
       VPODetailDataModel *detailModel = [VPODetailDataModel new];
        [detailModel setValuesForKeysWithDictionary:detailDict];
        model.data = detailModel;
    } else {
        
        model.data = [VPODetailDataModel new];
    }
    
    return model;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key{};

- (NSString *)description {
    
    return [NSString stringWithFormat:@"action = %@\n arg1 = %ld \n arg2 = %ld \n param1 = %@ \n param2 = %@ \n dName = %@ \n resultCode = %ld \n resultMsg = %@ \n data = {\ncardNum = %@ \n cardType = %ld \n track2 = %@ \n track3 = %@ \n} ", self.action,(long)self.arg1,(long)self.arg2,self.dName,self.param1,self.param2,(long)self.resultCode,self.resultMsg,self.data.cardNum,(long)self.data.cardType,self.data.track2,self.data.track3];
}

@end


@implementation VPODetailDataModel

- (void)setValue:(id)value forUndefinedKey:(NSString *)key{};

@end
